package com.lb.utils;

import java.util.Random;
import java.util.UUID;

public class RandomId {

        // 生成标准的UUID
        public static String generateUUID() {
            return UUID.randomUUID().toString().replaceAll("-", ""); // 去掉UUID中的短横线
        }
        // 生成自定义长度的随机字符串ID
        public static String generateRandomStringId(int length) {
            String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            Random random = new Random();
            StringBuilder sb = new StringBuilder(length);
            for (int i = 0; i < length; i++) {
                int randomIndex = random.nextInt(characters.length());
                sb.append(characters.charAt(randomIndex));
            }
            return sb.toString();


    }
}
